package com.yunkeji.common.enums.app;

import com.yunkeji.common.exception.AppServiceException;
import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Optional;

@Getter
@AllArgsConstructor
public enum StartCallType {
    定向视频(201),
    随机视频(202),
    客服视频(203);
    private Integer code;

    public static StartCallType getByCode(Integer code) {
        StartCallType[] values = StartCallType.values();
        Optional<StartCallType> first =
                Arrays.stream(values).filter(item -> item.getCode().equals(code)).findFirst();
        if (first.isPresent()) {
            return first.get();
        } else {
            throw AppServiceException.paramException("视频类型参数异常");
        }
    }
}
